home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.5 KB | 139 lines | [TEXT/ToyS] |
- property gfiDestFolder : ""
-
- property gfiRecursePath : "" --"Contains path down to where the files are from where they started
- property kfiRecurseDepth : 32
- property kfiOnlyFiles : true
- property kfiOnlyFolders : false
- property kfiDoInvisibles : false
-
-
-
- on open fsObj
- repeat with x in fsObj
- fiRecurse(fiAliasToCmd(x), kfiRecurseDepth)
- end repeat
- end open
-
-
- on fiOpenAgt(fileCmd)
- fiIsPowered(fcAlias of fileCmd, true)
- end fiOpenAgt
-
-
-
- on fiRecurse(fileCmd, levels)
- -- Walks a folder, sending all files to "open", levels is the maximum depth to go
- -- The global property gfiRecursePath contains the folders up to where we are
- --
- -- 27.06.97 Take fileCmd as parm, support files & folders, correct bug in missing the parent folder of a file when kfiOnlyFiles is FALSE
- if (isFolder of fileCmd) then
- if (not kfiOnlyFiles) then fiOpenAgt(fileCmd)
-
- -- Save our taken route and add this folder onto the current route
- set savePath to gfiRecursePath
- set gfiRecursePath to savePath & (fcName of fileCmd) & ":"
-
- -- Get parent path of subsequent objects and a list of them
- set fsDad to (fcAlias of fileCmd) as string
- set folderContents to list folder (fcAlias of fileCmd)
-
- -- Walk the objects
- repeat with objName in folderContents
- set thing to fiAliasToCmd((fsDad & objName) as alias)
- -- Process only if visible?
- if (kfiDoInvisibles or isVis of thing) then
- if (isFolder of thing) then
- -- Further recursion?
- if (kfiRecurseDepth > 0) then
- if (levels is 0) then
- dgMsg(kerTooDeep)
- else
- fiRecurse(thing, levels - 1)
- end if
- end if
- else if (not kfiOnlyFolders) then
- fiOpenAgt(thing)
- end if
- end if
- end repeat
-
- set gfiRecursePath to savePath
- else if not kfiOnlyFolders then
- fiOpenAgt(fileCmd)
- end if
- end fiRecurse
-
-
-
- on fiAliasToCmd(fsObj)
- -- This stores an alias and its info in one record
- set fsName to fsObj as string
- set isFold to (last character of fsName is ":")
- if (isFold) then set fsName to text from character 1 to -2 of fsName -- chop off colon
-
- -- Break on path breaks
- set saveDelims to the text item delimiters
- set the text item delimiters to ":"
-
- -- Break it down…
- set objName to the last text item of fsName
- set objVolume to the first text item of fsName
- set objFolder to the text from character 1 to ((length of fsName) - (length of objName)) of fsName
-
- -- Restore delimiters
- set the text item delimiters to saveDelims
-
- -- new FileCmd
- script fileCmd
- property isVis : true -- boolean
- property isFolder : isFold -- boolean
- property fcAlias : fsObj -- alias
- property fcVolume : objVolume -- string
- property fcParent : objFolder -- string
- property fcName : objName -- string
- end script
-
- return fileCmd
- end fiAliasToCmd
-
-
-
- property kfiPoweredHeader : "Joy!peffpwpc"
-
- on fiIsPowered(aliasObj, slimDown)
- set isPowered to false
- set headLen to (length of kfiPoweredHeader)
-
- set fInfo to basic info for aliasObj
-
- if (data fork length of fInfo ≥ headLen) then
- set forkRef to open fork from aliasObj write access slimDown
-
- if (forkRef > 0) then
- set headerText to read data from forkRef ¬
- using buffer size headLen with «class text»
-
- set isPowered to (headerText = kfiPoweredHeader)
-
- -- Kill data fork if requested and it's PowerPC code
- if (isPowered and slimDown) then
- set err to size fork forkRef given «class len »:0
- if (err is not 0) then beep
- end if
-
- close fork forkRef
- else
- beep
- end if
- end if
-
- return isPowered
- end fiIsPowered
-
-
-
-
- on dgMsg(msgStr)
- display dialog msgStr buttons {"Damn!"} default button 1
- end dgMsg
-